package ua.yandex.skipasssystem.skipass.validators;

import ua.yandex.skipasssystem.skipass.NumberOfLiftsInterface;
import ua.yandex.skipasssystem.skipass.SkiPass;

import java.time.LocalDateTime;

public class NumberOfLiftsSkiPassValidator extends
        WithDaysOfWorkingSkiPassValidator {

    private NumberOfLiftsSkiPassValidator() {
    }

    public static NumberOfLiftsSkiPassValidator getValidator() {
        return ValidatorHolder.VALIDATOR_HOLDER;
    }

    @Override
    public boolean validate(SkiPass skiPass,
                            LocalDateTime dateTime) {
        boolean isCorrectDateAndActive =
                super.validate(skiPass, dateTime);

        return isCorrectDateAndActive && isWorkAtDay(skiPass, dateTime)
                && ((NumberOfLiftsInterface) skiPass).
                getNumberOfLifts() > 0;
    }

    public static class ValidatorHolder {
        public static final NumberOfLiftsSkiPassValidator VALIDATOR_HOLDER =
                new NumberOfLiftsSkiPassValidator();
    }
}